package com.foreveross.fetl.core.domain.freight;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Query;

import org.springframework.transaction.annotation.Transactional;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.domain.BaseEntity;
import com.foreveross.fetl.core.domain.freight.repository.IFdcPortRepository;

@javax.persistence.Table(name = "FDC_PORT")
@javax.persistence.Entity
public class FdcPortEntity extends BaseEntity {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private Integer id;
	/**
	 * 三字码
	 */
	@Column(name = "CODE")
	private String code;
	@Column(name = "FOUR_CODE")
	private String fourCode;
	/**
	 * 机场名称
	 */
	@Column(name = "NAME")
	private String name;
	@Column(name = "ALIAS_NAME")
	private String aliasName;

	@Column(name = "HOT_LEVEL")
	private Integer hotLevel;

	@Column(name = "CREATE_TIME")
	private Date createTime = new Date();

	@Column(name = "UPDATE_TIME")
	private Date updateTime;

	@Column(name = "CITY_ID")
	private Integer cityId;
	/**
	 * 城市名称
	 */
	@Column(name = "CITY_NAME")
	private String cityName;

	@Column(name = "PRIORITY")
	private int priority;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getFourCode() {
		return fourCode;
	}

	public void setFourCode(String fourCode) {
		this.fourCode = fourCode;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAliasName() {
		return aliasName;
	}

	public void setAliasName(String aliasName) {
		this.aliasName = aliasName;
	}

	public Integer getHotLevel() {
		return hotLevel;
	}

	public void setHotLevel(Integer hotLevel) {
		this.hotLevel = hotLevel;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getCityId() {
		return cityId;
	}

	public void setCityId(Integer cityId) {
		this.cityId = cityId;
	}

	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}

	public IFdcPortRepository getIFdcPortRepository() {
		return InstanceFactory.getInstance(IFdcPortRepository.class);
	}

	@Transactional
	public void saveOrUpdate(FdcPortEntity entity) {
		if (null != entity.getId()) {
			getIFdcPortRepository().update(entity);
			return;
		}
		getIFdcPortRepository().save(entity);
	}

	@Transactional
	public void delete(FdcPortEntity entity) {
		getIFdcPortRepository().delete(entity);
	}

	public Query createQuery(String hql, Object[] params) {
		return getIFdcPortRepository().createQuery(hql, params);
	}

	public FdcPortEntity get(Integer id) {
		return getIFdcPortRepository().find(FdcPortEntity.class, id);
	}
}
